package a3_p04_ng_sw;


import org.jgrapht.WeightedGraph;
import org.jgrapht.graph.AbstractGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.junit.Test;


import static org.junit.Assert.assertEquals;





public class TestAlgo {
	
	AbstractGraph<String, DefaultEdge> graph1;
	AbstractGraph<String, DefaultEdge> graph2;
	AbstractGraph<String, DefaultEdge> k5;
	
	AbstractGraph<Knoten, DefaultWeightedEdge> graph3;
	AbstractGraph<Knoten, DefaultWeightedEdge> prim;
	
	WeightedGraph<Knoten, DefaultWeightedEdge> astar;
	
	
	AlgoDFS dfs1;
	AlgoDFS dfs2;
	AlgoDFS dfs3;
	
	AlgoBFS bfs1;
	AlgoBFS bfs2;
	AlgoBFS bfs3;
	
	AlgoDFS djkstra;
	AStar aStarAlgo;
	
	AlgoKruskal aKrus;
	AlgoPrim aPrim;
	AlgoPrimFibo aPrimFibo;
	
	
	private void init(){
			
		
	
			graph1 = (AbstractGraph<String, DefaultEdge>) ReadFile.getInstance().getGraph("graph1.gka");
	
			graph2 = (AbstractGraph<String, DefaultEdge>) ReadFile.getInstance().getGraph("graph2.gka");
	
			graph3 = (AbstractGraph<Knoten, DefaultWeightedEdge>) ReadFile.getInstance().getGraph("graph3.gka");
			
			k5     = (AbstractGraph<String, DefaultEdge>) ReadFile.getInstance().getGraph("k5.gka");
		
			astar = (WeightedGraph<Knoten, DefaultWeightedEdge>) ReadFile.getInstance().getGraph("graph3.gka");
			
			prim = (AbstractGraph<Knoten, DefaultWeightedEdge>) ReadFile.getInstance().getGraph("graph4.gka");
		
		dfs1 = new AlgoDFS(graph1, "a", "f");
		dfs2 = new AlgoDFS(graph2, "a", "f");
		dfs3 = new AlgoDFS(k5, "a", "c");
		
		bfs1 = new AlgoBFS(graph1, "a", "f");
		bfs2 = new AlgoBFS(graph2, "a", "f");
		bfs3 = new AlgoBFS(k5, "a", "c");
		
		djkstra = new AlgoDFS(graph3, "Hameln", "Hamburg");
		
		aStarAlgo = new AStar(astar,new Knoten("Bremen",95),new Knoten("Hamburg",0));
		
		aKrus = new AlgoKruskal(prim);
		aPrim = new AlgoPrim(prim);
		aPrimFibo = new AlgoPrimFibo(prim);
		
//		
	}
	
	@Test
	public void dfsTest(){
		init();
		//Kanten
		assertEquals(4,dfs1.getBenoetigteKanten());
		assertEquals(2,dfs2.getBenoetigteKanten());
		assertEquals(1,dfs3.getBenoetigteKanten());
		
		
	}
	@Test
	public void bfsTest(){
		init();
		//Kanten
		assertEquals(4,bfs1.getBenoetigteKanten());
		assertEquals(2,bfs2.getBenoetigteKanten());
		assertEquals(1,bfs3.getBenoetigteKanten());
				
	}
	
//	@Test
//	public void AStar(){
//		init();
//		assertEquals(djkstra.getTheShortestWay(),aStarAlgo.getTest());
//		
		
//	}
	@Test
	public void APrim(){
		init();
		assertEquals(aKrus.getGewicht(), aPrim.getGewicht());
		assertEquals(aPrim.getGewicht(), aPrimFibo.getGewicht());
		assertEquals(aKrus.getGewicht(), aPrimFibo.getGewicht());
		
//		assertEquals(aKrus.getMiniGraph(),aPrim.getMiniGraph());
//		assertEquals(aPrim.getMiniGraph(),aPrimFibo.getMiniGraph());
//		assertEquals(aKrus.getMiniGraph(),aPrimFibo.getMiniGraph());
		
	}

}
